lnmp access denied解决方案

  • 前提:lnmp安装完成后,访问页面出现access denied
  • vim /usr/local/nginx/conf/vhost/xxx.conf 添加三行,如下
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
server {
listen 8000;
server_name alitong.com;
access_log off;
index index.html index.htm index.php;
root /code/ali_childrens_electric_business_live;

include /usr/local/nginx/conf/rewrite/ecshop.conf;
#error_page 404 /404.html;
#error_page 502 /502.html;

#允许跨域,仅测试开放
location / {
add_header Access-Control-Allow-Origin *;
}

location ~ [^/]\.php(/|$) {
#增加下面三行
fastcgi_split_path_info ^(.+\.php)(/?.+)$;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
#fastcgi_pass remote_php_ip:9000;
fastcgi_pass unix:/dev/shm/php-cgi.sock;
fastcgi_index index.php;
include fastcgi.conf;
}

location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|flv|mp4|ico)$ {
expires 30d;
access_log off;
}
location ~ .*\.(js|css)?$ {
expires 7d;
access_log off;
}
location ~ /\.ht {
deny all;
}
}
  • 重启nginx,解决
1
service nginx restart
  • 如果上面操作之后还不行 vim /usr/local/php/etc/php.ini
1
2
3
#yyp复制一行备份
cgi.fix_pathinfo=1
;cgi.fix_pathinfo=0
-------------本文结束感谢您的阅读,如有问题,请在下方留言-------------

本文标题:lnmp access denied解决方案

文章作者:Ocean

发布时间:2018年05月12日 - 17:05

原始链接:https://oceandlnu.github.io/2018/05/12/lnmp access denied解决方案/

许可协议: 署名-非商业性使用-禁止演绎 4.0 国际 转载请保留原文链接及作者。